import React, { useState, useEffect, useCallback, useMemo } from "react";


function Callback(){
    const [name, setName] = useState('Millet');

    useEffect(() => {
        setInterval(() => {
            setName(oldName => oldName + 'Mike')
        }, 1000);
    }, []);

    const sayHi = useCallback(() => {
        alert('Hi');
    }, []);

    const sayHello = useMemo(() => {
        return () => alert('Hello');
    }, []);

    return(
        <div>
           <Children name={name} sayHello={sayHello} />
        </div>
    )
}


class Children extends React.PureComponent {
    render() {
        return (
            <div>{this.props.name}</div>
        )
    }
}

export default Callback;